using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using buildingLib.engineering;
using _dmis.engineering;
namespace _dmis.query
{
    public partial class DoorMaintainsDlg : _dmis.UIToolBase
    {
        MaintainList m_maintainLst;
        MaintainInfoDlg m_info = null;
        public DoorMaintainsDlg(Guid doorid)
        {
            InitializeComponent();
            m_maintainLst = MaintainList.GetDoorMaintainList(doorid);
        }

        private void DoorMaintainsDlg_Load(object sender, EventArgs e)
        {
            maintainListBindingSource.DataSource = m_maintainLst;
        }

        private void maintainListDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1 && e.ColumnIndex == 0)
            {
                if (m_info == null)
                {
                    m_info = new MaintainInfoDlg();
                    m_info.Location = new Point(this.Right + SystemInformation.FrameBorderSize.Width, this.Location.Y);
                    m_info.FormClosing += new FormClosingEventHandler(CloseInfoDlg);
                    m_info.GetMaintainInfo(((MaintainInfo)this.maintainListBindingSource.Current).ID);
                    m_info.Show(this);
                }
                else
                {
                    m_info.GetMaintainInfo(((MaintainInfo)this.maintainListBindingSource.Current).ID);
                }
                
            }
        }

        private void CloseInfoDlg(object sender, FormClosingEventArgs e)
        {
            m_info.FormClosing -= new FormClosingEventHandler(CloseInfoDlg);
            m_info = null;
        }

        private void DoorMaintainsDlg_Move(object sender, EventArgs e)
        {
            if (m_info != null)
            {
                Rectangle rect = this.Bounds;
                m_info.Location = new Point(this.Right + SystemInformation.FrameBorderSize.Width, this.Location.Y);
            }
        }
    }
}

